#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
typedef long long ll;
const int N = 2e5 + 10;
ll qui(ll a, ll b)
{
    ll res = 1;
    while (b)
    {
        if (b & 1)
            res = res * a % MOD;
        b >>= 1;
        a = a * a % MOD;
    }
    return res;
}

ll fac[N], inv_fac[N];

void init()
{
    fac[0] = 1;
    for (int i = 1; i < N; i++)
        fac[i] = fac[i - 1] * i % MOD;
    inv_fac[N - 1] = qui(fac[N - 1], MOD - 2);
    for (int i = N - 1; i > 0; i--)
        inv_fac[i - 1] = inv_fac[i] * i % MOD;
}

ll comb(int a, int b)
{
    return fac[a] * inv_fac[b] % MOD * inv_fac[a - b] % MOD;
}

void solve() {
    string s;
    cin >> s;
    vector<int> a;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++) {
        if(i && s[i] != s[i - 1]) {
            a.push_back(cnt);
            cnt = 1;
        }else cnt++;
    }
    if(cnt) a.push_back(cnt);
    cout << s.size() - a.size() << ' ';
    vector<int> b;
    cnt = 0;
    for(auto x : a) if(x > 1) b.push_back(x), cnt += (x - 1);
    ll ans = 1;
    for(auto x : b) {
        ans = (ans * comb(x, x - 1)) % MOD; 
    }
    ans = (ans * fac[cnt]) % MOD;
    cout << ans << endl;
}

int main() {
    init();
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}